package com.vint.leetcode;


/*
 * 1. done
 * 2. easy
 */
public class Leetcode494 {
	private int sum = 0;
	public int findTargetSumWays(int[] nums, int S) {
		sumA(nums,0,S,0);
		return sum;
	}

	public void sumA(int[]nums, int i, int s, int tmp) {
		if(i==nums.length-1){
			if(s==tmp+nums[i])sum++;
			if(s==tmp-nums[i]) sum++;
		}else{
			sumA(nums, i+1, s, tmp + nums[i]);
			sumA(nums, i+1, s, tmp - nums[i]);
		}
	}
	public void main(String[] args){
		Leetcode494 leetcode494 = new Leetcode494();
	}

}
